package cep.model.cep.model.dao.impl;

import cep.model.entity.core.*;
import cep.model.dao.CoreDao;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.PersistenceUnit;
import java.util.Date;
import java.util.List;

/**
 * User: golovin
 * Date: 17.06.13
 * Time: 22:53
 */
public class CoreDaoImplMock implements CoreDao {
    @PersistenceUnit
    private EntityManagerFactory emf;
    private final Log LOG = LogFactory.getLog(getClass());

    @Override
    public List<Office> getOffices() {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public Person getPerson(int id) {
        LOG.info("start getPerson. emf=" + emf);
        EntityManager em = emf.createEntityManager();
        EntityTransaction tx = em.getTransaction();
        tx.begin();
        LOG.info("tx opened");
        Person p = em.find(Person.class, id);
        tx.commit();
        LOG.info("tx closed");
        return  p;
    }

    @Override
    public Department getHeadDepartment() {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<Absence> getAbsencesByDate(Date startDate, Date endDate) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }

    @Override
    public List<Absence> getAbsencesByPerson(int id) {
        return null;  //To change body of implemented methods use File | Settings | File Templates.
    }
}
